﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace ScrumTable.UI.View.Controls
{
	/// <summary>
    /// Interaction logic for LoadingImageControl.xaml
	/// </summary>
	public partial class LoadingImageControl
	{
        private ImageSource _image;
	    
        public LoadingImageControl()
        {
            Loaded += OnLoaded;
		}

       

	    public void ShowImage(ImageSource source)
	    {
	        if(IsLoaded)
	        {
                Content = new Image { Source = source };
	        }
	        else
	        {
                _image = source;
	        }
	    }

        public void ShowWaitControl()
        {
            if (!(Content is WaitControl))
            {
                Content = new WaitControl() {MinHeight = 20, MinWidth = 20};
            }
        }
        

        private void OnLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            Loaded -= OnLoaded;
            InitializeComponent();

            if (_image != null)
            {
                Content = new Image { Source = _image };
            }
        }
	}
}